package com.ywwxhz.plugins.battery.widget;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;

import com.ywwxhz.Util.Config;
import com.ywwxhz.plugins.battery.BatteryModel;
import com.ywwxhz.service.CoreService;

public class BatteryWidget extends AppWidgetProvider {

    @Override
    public void onDeleted(Context context, int[] appWidgetIds) {
        Intent updateIntent = new Intent(context, CoreService.class);
        updateIntent.putExtra(Config.SERVICE_PARAM, BatteryModel.MODEL);
        updateIntent.putExtra(BatteryModel.PARAM, BatteryModel.WIDGET_DISABLE);
        context.startService(updateIntent);
        super.onDeleted(context, appWidgetIds);
    }


    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
                         int[] appWidgetIds) {
        Intent updateIntent = new Intent(context, CoreService.class);
        updateIntent.putExtra(Config.SERVICE_PARAM, BatteryModel.MODEL);
        updateIntent.putExtra(BatteryModel.PARAM, BatteryModel.WIDGET_ENABLE);
        context.startService(updateIntent);
        super.onUpdate(context, appWidgetManager, appWidgetIds);
    }
}
